using System;
using System.Data;
using digit.Core;

namespace SMS.ServiceManager
{
    public class MessageOutData
    {
        #region CONSTRUCTORS
        public MessageOutData(string connectionString)
        {
            this.m_connectionString = connectionString;
        }
        #endregion

        #region ATTRIBUTES
        const string SQL_INSERT = "vn1102_Insert_MessageOut";
        const string SQL_UPDATE = "vn1102_Update_MessageOut";
        const string SQL_DELETE = "vn1102_Delete_MessageOut";
        const string SQL_SELECTONE = "vn1102_Select_MessageOut";
        const string SQL_SELECTALL = "vn1102_SelectAll_MessageOut";
        const string SQL_SEARCH = "vn1102_Search_MessageOut";
        private string m_connectionString;
        #endregion

        #region METHODS
        public bool Insert(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, SQL_INSERT, values);
            return i > 0;
        }

        public bool Update(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, SQL_UPDATE, values);
            return i > 0;
        }

        public bool Delete(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, SQL_DELETE, values);
            return i > 0;
        }

        public DataSet GetAllMessages_ForSend()
        {
            return DataAccess.FillDataSet(this.m_connectionString, "vn1102_Select_All_MessageOut_Process", true);
        }

        public bool UpdateStatus(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, "vn1102_Update_MessageOut_Status", values);
            return i > 0;
        }

        public DataTable SelectAll_Network_ByServiceID(string serviceId)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Select_AllNetwork_MsgOut_ByServiceID", serviceId, true);
        }

        public DataTable StatisticMsgOut_ByServiceID_Online(string serviceId)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageOut_ByServiceID_Online", serviceId, true);
        }

        public DataTable StatisticMsgCdr_ByServiceID_Online(string serviceId)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageCDR_ByServiceID_Online", serviceId, true);
        }

        public DataTable SearchMsgOut_ByServiceID_Online(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Search_MsgOutByServiceID_Online", values, true);
        }

        public DataTable StatisticMsgOut_ByService_Online(string service)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageOut_ByService_Online", service, true);
        }

        public DataTable StatisticMsgCdr_ByService_Online(string service)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageCDR_ByService_Online", service, true);
        }

        public DataTable StatisticMsgOut_ByServiceID(string serviceId)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageOut_ByServiceID", serviceId, true);
        }

        public DataTable StatisticMsgCdr_ByServiceID(string serviceId)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageCDR_ByServiceID", serviceId, true);
        }

        public DataTable StatisticMsgOut_ByService(string service)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageOut_ByService", service, true);
        }

        public DataTable StatisticMsgCdr_ByService(string service)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Statistics_MessageCDR_ByService", service, true);
        }

        public bool InsertError(string Error)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, "vn1102_Insert_ProcessOutLogs", Error);
            return i > 0;
        }

        public int InsertMT(object[] values)
        {
            return DataAccess.ExecuteStoreProcedure(this.m_connectionString, "vn1102_Insert_MessageOutMT", values);
        }

        public DataTable Select(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, SQL_SELECTONE, values, true);
        }

        public DataTable SelectAll()
        {
            return DataAccess.FillTable(this.m_connectionString, SQL_SELECTALL, true);
        }

        public bool Update_MsgInOut_Loading()
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, "vn1102_Update_MsgInOut_Loading");
            return i > 0;
        }

        public DataTable GetMsgOut()
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Get_MsgOut", true);
        }

        public DataTable GetMsgOutVms()
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Get_MsgOut_Vms", true);
        }

        public DataTable GetMsgOutGpc()
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Get_MsgOut_Gpc", true);
        }

        public DataTable GetMsgOutViettel()
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Get_MsgOut_Viettel", true);
        }

        #endregion

    }
}